package com.kzw.misc.bean;

import org.apache.commons.beanutils.PropertyUtils;

public class Bean {

	private Object c0;
	private Object c1;
	private Object c2;
	private Object c3;
	private Object c4;
	private Object c5;
	private Object c6;
	private Object c7;
	private Object c8;
	private Object c9;
	private Object c10;
	private Object c11;
	private Object c12;
	private Object c13;
	private Object c14;

	public Bean() {
	}

	public Bean(Object... objects) {
		int maxlen = (objects.length > 15 ? 15 : objects.length);
		for (int i = 0; i < maxlen; i++) {
			try {
				PropertyUtils.setProperty(this, "c" + i, objects[i]);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	public static void main(String[] args) {
		Bean b = new Bean(1, 2, 3);
		System.out.println(b);
	}

	public void init() {
		this.c0 = "";
		this.c1 = "";
		this.c2 = "";
		this.c3 = "";
		this.c4 = "";
		this.c5 = "";
		this.c6 = "";
		this.c7 = "";
		this.c8 = "";
		this.c9 = "";
		this.c10 = "";
		this.c11 = "";
		this.c12 = "";
		this.c13 = "";
		this.c14 = "";
	}

	public Object getC0() {
		return c0;
	}

	public void setC0(Object c0) {
		this.c0 = c0;
	}

	public Object getC1() {
		return c1;
	}

	public void setC1(Object c1) {
		this.c1 = c1;
	}

	public Object getC2() {
		return c2;
	}

	public void setC2(Object c2) {
		this.c2 = c2;
	}

	public Object getC3() {
		return c3;
	}

	public void setC3(Object c3) {
		this.c3 = c3;
	}

	public Object getC4() {
		return c4;
	}

	public void setC4(Object c4) {
		this.c4 = c4;
	}

	public Object getC5() {
		return c5;
	}

	public void setC5(Object c5) {
		this.c5 = c5;
	}

	public Object getC6() {
		return c6;
	}

	public void setC6(Object c6) {
		this.c6 = c6;
	}

	public Object getC7() {
		return c7;
	}

	public void setC7(Object c7) {
		this.c7 = c7;
	}

	public Object getC8() {
		return c8;
	}

	public void setC8(Object c8) {
		this.c8 = c8;
	}

	public Object getC9() {
		return c9;
	}

	public void setC9(Object c9) {
		this.c9 = c9;
	}

	public Object getC10() {
		return c10;
	}

	public void setC10(Object c10) {
		this.c10 = c10;
	}

	public Object getC11() {
		return c11;
	}

	public void setC11(Object c11) {
		this.c11 = c11;
	}

	public Object getC12() {
		return c12;
	}

	public void setC12(Object c12) {
		this.c12 = c12;
	}

	public Object getC13() {
		return c13;
	}

	public void setC13(Object c13) {
		this.c13 = c13;
	}

	public Object getC14() {
		return c14;
	}

	public void setC14(Object c14) {
		this.c14 = c14;
	}

	@Override
	public String toString() {
		StringBuffer sb = new StringBuffer("Bean[");
		for (int i = 0; i < 15; i++) {
			try {
				Object val = PropertyUtils.getProperty(this, "c" + i);
				if (val != null) {
					sb.append("c" + i + "=" + val + ",");
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		if (sb.length() > 8) {
			sb.deleteCharAt(sb.length() - 1);
		}
		sb.append("]");
		return sb.toString();
	}

}
